package homework.api05;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class BufferedCopyDemo {
    public static void main(String[] args) throws IOException {

        //复制图片，先读取再输出。
        FileInputStream fis = new FileInputStream("src/ysx.webp");
        BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos1 = new FileOutputStream("ysx-xrq.jpg");
        BufferedOutputStream bos1 = new BufferedOutputStream(fos1);
        int len;
        long start = System.currentTimeMillis();
        while ((len=bis.read())!=-1){
            bos1.write(len);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
        bos1.flush();
        long end1 =System.currentTimeMillis();
        System.out.println(end1-end);
        bos1.close();
        fos1.close();
        bis.close();
        fis.close();
    }
}
